// https://nuxt.com/docs/api/configuration/nuxt-config
import path from 'node:path'
import process from 'node:process'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'

export default defineNuxtConfig({
  app: {},
  runtimeConfig: {
    serverBaseApi: {
      dev: 'https://jav-client-gateway.dev.zhanggao223.com/client-gateway/client-server/',
      test: 'https://jav-client-gateway.test.zhanggao223.com/client-gateway/client-server/',
      pre: 'https://jav-client-gateway.pre.zhanggao223.com/client-gateway/client-server/',
      release: 'https://jcgw.ozozhv.com/client-gateway/client-server/'
    }
  },
  imports: {
    dirs: ['store']
  },
  vite: {
    plugins: [
      createSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), 'assets/icon')]
      })
    ],
    server: {
      proxy: {
        '/api': {
          target: 'https://www.mtgkdr.com/',
          changeOrigin: true
        }
      }
    }
  },
  css: ['@unocss/reset/tailwind.css', '~/assets/style/base.css', '~/assets/style/transition.css'],
  modules: [
    '@vueuse/nuxt',
    '@unocss/nuxt',
    '@nuxt/image',
    'nuxt-swiper',
    'nuxt-gtag',
    [
      '@pinia/nuxt',
      {
        autoImports: ['defineStore', 'storeToRefs']
      }
    ],
    'nuxt-lodash',
    '@nuxtjs/device',
    'nuxt-vite-legacy',
    'dayjs-nuxt'
  ],
  gtag: {
    id: process.env.VITE_APP_GOOGLE_GTAG_ID
  },
  legacy: {
    targets: ['defaults', 'not IE 11']
  },
  devServer: {
    host: '0.0.0.0',
    port: 9002
  },
  build: {
    analyze: {
      analyzerMode: 'static'
    }
  },
  experimental: {
    payloadExtraction: false,
    inlineSSRStyles: false,
    renderJsonPayloads: true,
    typedPages: true
  },
  devtools: { enabled: true },
  ssr: true,
  spaLoadingTemplate: 'spa-loading-template.html'
})
